package com.zyp.springdemo;

import com.zyp.springdemo.service.impl.HelloMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;

import static java.lang.System.exit;

public class SpringBootConsoleApplication implements CommandLineRunner {
    @Autowired
    private HelloMessageService helloService;

    public static void main(String[] args) throws Exception {
        //disabled banner, don't want to see the spring logo
        System.out.println("start...");
//        SpringApplication app = new SpringApplication(SpringBootConsoleApplication.class);
//        app.setBannerMode(Banner.Mode.OFF);
//        app.run(args);

    }

    // Put your logic here.
    @Override
    public void run(String... args) throws Exception {

        if (args.length > 0) {
            System.out.println(helloService.getMessage(args[0].toString()));
        } else {
            System.out.println(helloService.getMessage());
        }

        exit(0);
    }
}
